﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProductKeysWin;
using System.Globalization;

namespace ProductKeyDB
{
    public partial class Product
    {
        #region Extensibility Method Definitions
        partial void OnSearchSimilarityChanging(System.Nullable<decimal> value);
        partial void OnSearchSimilarityChanged();
        #endregion

        public decimal GetSimilarity(string search)
        {
            SearchSimilarity = search.CalculateSimilarity(this.Name.ToLower(CultureInfo.CurrentCulture));
            return SearchSimilarity;
        }

        public decimal ZeroSimilarity()
        {
            string empty = "";
            SearchSimilarity = empty.CalculateSimilarity(this.Name.ToLower(CultureInfo.CurrentCulture));
            return SearchSimilarity;
        }

        private decimal _SearchSimilarity;

        public decimal SearchSimilarity
        {
            get
            {
                return this._SearchSimilarity;
            }
            set
            {
                if ((this._SearchSimilarity != value))
                {
                    this.OnSearchSimilarityChanging(value);
                    this.SendPropertyChanging();
                    this._SearchSimilarity = value;
                    this.SendPropertyChanged("SearchSimilarity");
                    this.OnSearchSimilarityChanged();
                }
            }
        }
    }
}
